﻿using System;
using System.Collections.Generic;
using Battle.Engine.InputData;

namespace Battle.Engine.LogicModel
{
    public class FAttribute
    {
        public double hp;//HP血量
        public double maxHp;//HP血量上限
        public double defaultmaxHp;
        public DataAttribute att;//攻击力
        public double defaultatt;
        public DataAttribute patt;//物理攻击力
        public double defaultpatt;
        public DataAttribute matt;//法术攻击力
        public double defaultmatt;
        public DataAttribute pdef;//物理防御
        public double defaultpdef;
        public DataAttribute mdef;//法术防御
        public double defaultmdef;
        public double hit;//命中
        public double defaulthit;
        public double dodge;//闪避
        public double defaultdodge;
        public double cri;//暴击
        public double defaultcri;
        public double antiCri;//抗暴击
        public double defaultantiCri;
        public double criFactor;//暴击系数
        public double defaultcriFactor;
        public double cure; //治疗值
        public double defaultcure;
        public double heal; //被治疗值
        public double defaultheal;
        public double treatAdd; //治疗加成
        public double defaulttreatAdd;
        public double damageAdd;//伤害加成
        public double defaultdamageAdd;
        public double damageReduce;//伤害减免
        public double defaultdamageReduce;
        public double pdamageReduce;//物理伤害减免
        public double defaultpdamageReduce;
        public double mdamageReduce;//法术伤害减免
        public double defaultmdamageReduce;


        //战斗中的属性
        public double angerRate; //技能怒气翻倍
        public double peranger; //技能（被击）怒气加成
        public double beHitAddAngerPercent; // 被击怒气增加百分比
        public double floatBreakHitFactor;  // 浮空倒地状态加成
        public double block; //格挡几率
        public double blockDam; //格挡伤害
        public double counterStrikeDam; //反伤伤害
        public bool counterStrikeReal; //是否反伤真实伤害
        public int counterStrikeSelect; // 反伤选择范围


        public double poisonDam; // 当前毒伤
        public double poison; // 毒伤加成
        public double antiPoison; // 毒免伤加成
        public double fireDam; // 当前火伤
        public double fire; // 火伤加成
        public double antiFire; // 火免伤加成
        public double minusDebuffOdds; // 中debuff减免概率
        public double minusDebuffperOdds; // 中debuff减免概率百分比
        public double lifestealHp; // 吸血
        public int lifestealSelect; // 吸血选择目标
        public double shield; // 血盾
        public double pshield; // 物理血盾
        public double mshield; // 魔法血盾
        public double rebound; // 复活血量
        public double minusAddperhp; // 降低恢复
        public double bleeding; // 流血
        public int magicStoneNum; // 炎魔石
        public List<FActor> damShareActors; // 分担血量的人
        public double damShareFactor; // 分担血量的数额
        public double sameDamForRandom; // 再随机一人附加减血为技能目标总减血的百分比

        public int angerTohpAF = 0;  //每AF点怒气
        public double angerTohpHF = 0; //抵消HF血量

        public double perhpreduceToangerHF = 0; //每降低HF血量
        public int perhpreduceToangerAF = 0;//增加AF点怒气

        public double hpMinusVal;               //减血值
        public double maxhpLimitDam = 0;   //最大减血限制
        public double hpChangeInRound;          //当前回合的血量变化

        public FAttribute(FActor actore, InActorData data)
        {
            this.hp = data.hp;
            this.maxHp = data.maxHp;
            this.att = new DataAttribute(data.att);//攻击力
            this.patt = new DataAttribute(data.patt);//物理攻击力
            this.matt = new DataAttribute(data.matt);//法术攻击力
            this.pdef = new DataAttribute(data.pdef);//物理防御
            this.mdef = new DataAttribute(data.mdef);//法术防御
            this.hit = data.hit * CommonMethod.tableAttributeConvert;//命中率
            this.dodge = data.dodge * CommonMethod.tableAttributeConvert;//闪避率
            this.cri = data.cri * CommonMethod.tableAttributeConvert;//暴击率
            this.antiCri = data.antiCri * CommonMethod.tableAttributeConvert;//抗暴率
            this.criFactor = data.criFactor * CommonMethod.tableAttributeConvert;//暴击系数
            this.cure = data.cure;//治疗值
            this.heal = data.heal;//被治疗值
            this.treatAdd = data.treatAdd * CommonMethod.tableAttributeConvert;//治疗加成
            this.damageAdd = data.damageAdd * CommonMethod.tableAttributeConvert;//伤害加成
            this.damageReduce = data.damageReduce * CommonMethod.tableAttributeConvert;//伤害减免   
            this.pdamageReduce = data.pdamageReduce * CommonMethod.tableAttributeConvert;//物理伤害减免    
            this.mdamageReduce = data.mdamageReduce * CommonMethod.tableAttributeConvert;//法术伤害减免       

            this.angerRate = 1;
            this.peranger = 0;
            this.beHitAddAngerPercent = actore.player.engineData.tableDataUtil.GetBeHitAddAngerFactor(); // 被击怒气增加百分比
            this.floatBreakHitFactor = actore.player.engineData.tableDataUtil.GetFloatBreakDodgeFactor();  // 浮空倒地状态加成
            this.block = 0; //格挡几率
            this.blockDam = 0; //格挡伤害
            this.counterStrikeDam = 0; //反伤伤害
            this.counterStrikeReal = false;
            this.poisonDam = 0; // 当前毒伤
            this.poison = 0; // 毒伤加成
            this.antiPoison = 0; // 毒免伤加成
            this.fireDam = 0; // 当前火伤
            this.fire = 0; // 火伤加成
            this.antiFire = 0; // 火免伤加成
            this.minusDebuffOdds = 0; // 中debuff减免概率
            this.minusDebuffperOdds = 0; // 中debuff减免概率百分比
            this.lifestealHp = 0; // 吸血
            this.lifestealSelect = 0;
            this.shield = 0; // 血盾
            this.pshield = 0;
            this.mshield = 0;
            this.rebound = 0; // 复活血量
            this.bleeding = 0;// 流血
            this.magicStoneNum = 0; // 炎魔石
            this.damShareActors = new List<FActor>();
            this.damShareFactor = 0;
            this.sameDamForRandom = 0;

            this.angerTohpAF = 0;  //每AF点怒气
            this.angerTohpHF = 0; //抵消HF血量

            this.perhpreduceToangerHF = 0; //每降低HF血量
            this.perhpreduceToangerAF = 0;//增加AF点怒气

            this.hpMinusVal = 0;
            this.maxhpLimitDam = 0;
            this.hpChangeInRound = 0;

            this.defaultmaxHp = data.maxHp;
            this.defaultatt = data.att;//攻击力
            this.defaultpatt = data.patt;//物理攻击力
            this.defaultmatt = data.matt;//法术攻击力
            this.defaultpdef = data.pdef;//物理防御
            this.defaultmdef = data.mdef;//法术防御
            this.defaulthit = data.hit * CommonMethod.tableAttributeConvert;//命中率
            this.defaultdodge = data.dodge * CommonMethod.tableAttributeConvert;//闪避率
            this.defaultcri = data.cri * CommonMethod.tableAttributeConvert;//暴击率
            this.defaultantiCri = data.antiCri * CommonMethod.tableAttributeConvert;//抗暴率
            this.defaultcriFactor = data.criFactor * CommonMethod.tableAttributeConvert;//暴击系数
            this.defaultcure = data.cure;//治疗值
            this.defaultheal = data.heal;//被治疗值
            this.defaulttreatAdd = data.treatAdd * CommonMethod.tableAttributeConvert;//治疗加成
            this.defaultdamageAdd = data.damageAdd * CommonMethod.tableAttributeConvert;//伤害加成
            this.defaultdamageReduce = data.damageReduce * CommonMethod.tableAttributeConvert;//伤害减免  
            this.defaultpdamageReduce = data.pdamageReduce * CommonMethod.tableAttributeConvert;//物理伤害减免  
            this.defaultmdamageReduce = data.mdamageReduce * CommonMethod.tableAttributeConvert;//法术伤害减免   
        }

        public void Reset()
        {
            this.maxHp = this.defaultmaxHp;
            this.att.Reset(this.defaultatt);
            this.patt.Reset(this.defaultpatt);
            this.matt.Reset(this.defaultmatt);
            this.pdef.Reset(this.defaultpdef);
            this.mdef.Reset(this.defaultmdef);
            this.hit = this.defaulthit;
            this.dodge = this.defaultdodge;
            this.cri = this.defaultcri;
            this.antiCri = this.defaultantiCri;
            this.criFactor = this.defaultcriFactor;
            this.cure = this.defaultcure;
            this.heal = this.defaultheal;
            this.treatAdd = this.defaulttreatAdd;
            this.damageAdd = this.defaultdamageAdd;
            this.damageReduce = this.defaultdamageReduce;
            this.pdamageReduce = this.defaultpdamageReduce;
            this.mdamageReduce = this.defaultmdamageReduce;
    }

        public void Clear()
        {
            this.defaultmaxHp = 0;
            this.defaultatt = 0;
            this.defaultpatt = 0;
            this.defaultmatt = 0;
            this.defaultpdef = 0;
            this.defaultmdef = 0;
            this.defaulthit = 0;
            this.defaultdodge = 0;
            this.defaultcri = 0;
            this.defaultantiCri = 0;
            this.defaultcriFactor = 0;
            this.defaultcure = 0;
            this.defaultheal = 0;
            this.defaulttreatAdd = 0;
            this.defaultdamageAdd = 0;
            this.defaultdamageReduce = 0;
            this.defaultpdamageReduce = 0;
            this.defaultmdamageReduce = 0;
            this.hp = 0;
            Reset();
        }

    }
}
